package com.weirong.smartvault.backservice.util.common;

import java.util.concurrent.atomic.AtomicInteger;

public class CashboxCommandIdGenerator {

    private static final int MAX_OF_3_BIT = 8388608;

    private static AtomicInteger CASHBOX_COMMAND_ID = new AtomicInteger(0);

    public static int getId()
    {
        int result = CASHBOX_COMMAND_ID.getAndIncrement();
        if(result >= MAX_OF_3_BIT) {
            CASHBOX_COMMAND_ID = new AtomicInteger(0);
            result = CASHBOX_COMMAND_ID.getAndIncrement();
        }
        return result;
    }

}
